﻿<controls:ChildWindow 
	x:Class="RIBA.Login"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
	xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
	xmlns:MVVMSL="clr-namespace:Riba.MVVMSL;assembly=RibaMVVMSL" 
	Width="400" Height="220" 
	Title="{Binding Path=TextResource.Login, Source={StaticResource App_TextResourceWrapper}}"
	Style="{StaticResource ChildWindowStyle}"
	DataContext="{Binding Source={StaticResource App_ViewModelLocator}, Converter={StaticResource App_ViewModelNameToViewModelConverter}, ConverterParameter=RIBA.Login_VM}"
	KeyUp="ChildWindow_KeyUp"
	IsEnabled="{Binding IsNoOperationPending}"
>
	<Grid Margin="2">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<MVVMSL:ViewEventHandlerControl />

		<StackPanel Grid.Row="0">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition />
					<RowDefinition Height="5" />
					<RowDefinition />
					<RowDefinition Height="20" />
					<RowDefinition />
				</Grid.RowDefinitions>
					
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="90" />
					<ColumnDefinition />
				</Grid.ColumnDefinitions>

				<TextBlock Text="{Binding Path=TextResource.Name, Source={StaticResource App_TextResourceWrapper}}" />
				<TextBox IsTabStop="True" TabIndex="0" Text="{Binding UserName, Mode=TwoWay}" Style="{StaticResource UpdateSourceOnKeystrokeTextBoxStyle}" Grid.Column="1" />

				<TextBlock Text="{Binding Path=TextResource.Password, Source={StaticResource App_TextResourceWrapper}}" Grid.Row="2" />
				<PasswordBox IsTabStop="True" TabIndex="1" Password="{Binding Password, Mode=TwoWay}" Style="{StaticResource UpdateSourceOnKeystrokePasswordBoxStyle}" Grid.Row="2" Grid.Column="1" />
				
				<TextBlock Text="{Binding Status}" Foreground="Red" Grid.Row="4" Grid.ColumnSpan="2" TextWrapping="Wrap" />
			</Grid>
		</StackPanel>

		<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
			<Button
				Content="{Binding Path=TextResource.Cancel, Source={StaticResource App_TextResourceWrapper}}"
				Click="CancelButton_Click"
				Width="80" Margin="0, 0, 2, 0"
			/>
			<Button
				Name="ButtonOk"
				Content="{Binding Path=TextResource.OK, Source={StaticResource App_TextResourceWrapper}}"
				Command="{Binding CommandOk, Mode=OneWay}"
				Width="80"
				IsTabStop="True" TabIndex="2"
			/>
		</StackPanel>

		<toolkit:BusyIndicator
			BusyContent="{Binding Path=TextResource.PleaseWait, Source={StaticResource App_TextResourceWrapper}}" 
			IsBusy="{Binding IsBusy}"
			Grid.RowSpan="3"
		/>
	</Grid>
</controls:ChildWindow>